var eventproxy=require('eventproxy');
var ep=new eventproxy();

function mockGet(cb){
    setTimeout(function () {
        console.log('网络请求...');
        cb(null,'网络请求');
    },Math.random()*1000|0);
}

function mockRead(cb){
    setTimeout(function () {
        console.log('读取文件...');
        cb(null,'读取文件');
    },Math.random()*1000|0);
}

function mockQuery(cb){
    setTimeout(function () {
        console.log('查询数据库...');
        cb(null,'查询数据库');
    },Math.random()*1000|0);
}

//--------------------------------

ep.tail('query','read', function (data1, data2) {
    console.info('tail:--------------------');
    console.log('read:',data1);
    console.log('query:',data2);
});

setInterval(function () {
    mockRead(function (err,data) {
        ep.emit('read',data);
    });
},3500);

setInterval(function () {
    mockQuery(function (err,data) {
        ep.emit('query',data);
    });
},3000);


